$(function(){
    var user = localStorage.getItem("user")
    if(user){
        $(".user").html(user)
        $(".login").remove()
        $(".register").remove()
        $(".logininfo").html('<a href="#" class="login-out">退出</a>')
        
    }
    $(".logininfo").on("click",".login-out",function(){
        localStorage.removeItem("user")
        window.location.reload();
    })
    $.ajax({
        url: "http://localhost/yidianzu/API/special.php",
        type: "get",
        dataType: "json",
        success: function (data) {
            var data = data
            console.log(data)
    
            var html = ""
            for (var i = 0; i < data.length; i++) {
                html = `
                
                        <a class="img-box" target="_blank" href="./detail.html?id=3">
                        <img class="product-pic"
                            src="${data[i].img_url}"
                            alt="">
                        </a>
                        <a target="_blank" href="./detail.html?id=3">
                            <p class="product-name">${data[i].title}</p>
                        </a>
                        <p class="product-config"><span>${data[i].s_desc}</span></p>
                        <div class="price-box">
                            <p class="old-price">${data[i].oldprice}</p>
                            <div class="price">
                                ¥<span class="red">${data[i].newprice}</span>/月
                            </div>
                        </div>
                        <div class="btn-box">
                            <a class="buy-btn" target="_blank" href="./detail.html?id=3">
                                <img class="price-sign" src="./image/list/subject-price-sign.png" alt="">
                                立即下单
                            </a>
                        </div>
                
                        `
                $(".item").eq(i).html(html)
                console.log(html)
            }
    
            // console.log($(".other").eq(i).html(html))
    
        }
    
    
    })
})
//获取数据
